package org.hw.proxy.cglib;

import net.sf.cglib.proxy.MethodInterceptor;
import net.sf.cglib.proxy.MethodProxy;

import java.lang.reflect.Method;

public class AnimalInterceptor implements MethodInterceptor {

    @Override
    public Object intercept(Object o, Method method, Object[] objects, MethodProxy methodProxy) throws Throwable {
        System.out.println("CG ProxyMethond before--------------------");
//        此处target是需要注入此类上午目标对象
//        method.invoke(target,objects);
        Object obj=methodProxy.invokeSuper(o,objects);
        System.out.println("CG ProxyMethond after--------------------");
        return obj;
    }
}
